#!/usr/bin/python
# -*- coding:utf-8 -*-
# @author  : micah
# @time    :  
# @function: 
# @version :

import pymysql


def create_table():
    db = pymysql.connect(host='localhost', port=3305, user='root', passwd='123456', db='python_test_1')
    cursor = db.cursor()

    cursor.execute("drop table if exists employee")

    # 创建字符串 - sql语句
    sql = """
        create table employee(
            first_name varchar(20) not null,
            last_name varchar(20),
            age int,
            sex varchar(1),
            income float,
            create_time datetime
            );
    """

    try:
        cursor.execute(sql)
        print('员工表创建成功..')
    except Exception as e:
        print('员工表创建失败： ', e)
    finally:
        cursor.close()
        db.close()


create_table()

